package lad02.test21;

import java.util.Scanner;
public class Test21 { public static void main(String[] args) {
    Scanner zzy = new Scanner(System.in);

    System.out.println("请输入一串字符:");
    String str = zzy.nextLine();

    System.out.println("请输入要查找的字符:");
    String s = zzy.nextLine();
    char a = s.charAt(0);

    int z= 0;
    for(int i = 0; i < str.length(); i++) {      // 遍历字符串，找出要查找的字符并输出其频率。
        if(str.charAt(i) == a) {
            z++;
        }
    }
    System.out.println("字符:" + s + "出现的频率是:"  + z);
}
}
